import React from 'react'
import { WingBlank, WhiteSpace, Card } from 'antd-mobile'
import { Link } from 'react-router-dom'
import './index.scss'

class CardList extends React.Component{

    render(){
        const { data } = this.props
        return (
            <WingBlank>
                <WhiteSpace/>
                { data.map( item => (
                    <div key={item._id}>
                        {/* ?username=${item.username}&avatar=${item.avatar}*/}
                        <Link to={{ pathname: `/chat/${item._id}` }}>
                            <Card>
                                <Card.Header
                                    title={item.username}
                                    thumb={require(`@/assets/images/avatar/${item.avatar}.png`)}
                                    extra={<span>{item.title}</span>}
                                    thumbStyle={{
                                        width: 22,
                                        height: 22
                                    }}
                                />
                                <Card.Body>
                                    { item.type === 'boss' && <p>公司名称：{item.company}</p> }
                                    { item.type === 'boss' && <p>职位薪资：{item.money}</p> }
                                    {item.type === 'genius'? '个人简介：' : '职位要求：' }
                                    {item.desc.split('\n').map((val, i) => (
                                        <p key={i}>{val}</p>
                                    ))}
                                </Card.Body>
                            </Card>
                        </Link>
                        <WhiteSpace/>
                    </div>
                ))}
            </WingBlank>
        )
    }
}

export default CardList